***HEADER**********************************************************

clear
clear matrix
set more off

foreach p in coefplot estout cibar {
	cap ssc install `p'
}

cap cd "***Set working directory here***"
use study1.dta, clear


***SAMPLE STATISTICS*************************************************
	
sum age edu female right pol
//For Supplementary Table 1


***BALANCE CHECK******************************************************

recode condition (1=3)(3=1), gen(condition3)
label define clabel3 1 "3-item" 2 "Placebo" 3 "Control" 4 "10-item"
	label values condition3 clabel3
recode condition (1=4)(4=1), gen(condition10)
label define clabel10 1 "10-item" 2 "Placebo" 3 "3-item" 4 "Control"
	label values condition10 clabel10
	
eststo balance1: mlogit condition3 age female edu pol right, b(3) r rrr
eststo balance2: mlogit condition3 age female edu pol right, b(2) r rrr
eststo balance3: mlogit condition10 age female edu pol right, b(3) r rrr
eststo balance4: mlogit condition10 age female edu pol right, b(2) r rrr
eststo balance5: mlogit condition3 age female edu pol right, b(4) r rrr
eststo balance6: mlogit condition age female edu pol right, b(1) r rrr

coefplot(balance1,label(3-item vs. Control) ciop(lc(gs0)) mc(gs0)) ///
		(balance3,label(10-item vs. Control) ciop(lc(gs2)) mc(gs2)) ///
		(balance5,label(3-item vs. 10-item) ciop(lc(gs4)) mc(gs4)) ///
		(balance2,label(3-item vs. Placebo) ciop(lc(gs6)) mc(gs6)) ///
		(balance4,label(10-item vs. Placebo) ciop(lc(gs8)) mc(gs8)) ///
		(balance6,label(Placebo vs. Control) ciop(lc(gs10)) mc(gs10)), ///
		drop(_cons) title("Study 1", color(black)) xline(1) eform xtitle(Odds ratio) ///
		legend(cols(1) ring(0) pos(4) bm(none) m(zero) si(small)) graphr(c(white))
graph export "../figures/suppfig1_1.eps", replace
eststo clear

local balance = "age"


***TREATMENT COMPLIANCE**************************************************

eststo check3: mean(three_fan three_light three_plug) if condition == 3
eststo check10: mean(ten_fan ten_light ten_plug ten_tv ten_chrg ten_wash ///
	ten_refr ten_rice ten_seat ten_bulb) if condition == 4

coefplot check3 check10, omitted baselevels ///
		 mlabel format(%9.2f) mlabposition(12) mlabcolor(black) mc(black) ciop(lc(black)) ///
		 legend(off) xtitle("Completion rate") graphr(c(white)) ///
		 title("Study 1", color(black)) ///
		 headings(three_fan = "{bf:3-item condition}" ///
		 ten_fan = "{bf:10-item condition}",labcolor(black))
graph export "../figures/suppfig2_1.eps", replace
eststo clear


***GOAL COMMITMENT*******************************************************

eststo comcontrol: ologit energy_com three ten placebo `balance', r
eststo complacebo: ologit energy_com three ten control `balance', r

coefplot (comcontrol,label(vs. Control) mc(gs0) ciop(lc(gs0)) mlabcolor(gs0)) ///
		 (complacebo,label(vs. Placebo) m(triangle) mc(gs6) ciop(lc(gs6)) mlabcolor(gs6)), ///
		 drop(`balance' control _cons) xline(1) eform xtitle(Odds Ratio) ///
		 mlabel format(%9.2f) mlabposition(12) mlabgap(*2) graphr(c(white)) ///
		 legend(ring(0) pos(7) si(small) cols(1) bm(medium))
graph export "../figures/suppfig3.eps", replace
eststo clear

	
***MAIN EFFECTS**************************************************************

//FIGURE 1
cibar support, over1(condition) barg(4) barc(gs1 gs1 gs7 gs7) ciopts(lc(gs10) lp(dash)) ///
	  gr(yti("Policy support (proportion)" " ") ///
	  ysc(r(0.2 0.4)) ylab(0.2(0.05)0.4,nogrid) ///
	  xlab(1 "Control" 2 "Placebo" 3 "3-item" 4 "10-item") ///
	  graphr(c(white)) leg(off))
graph export "../figures/fig1.eps", replace

//FIGURE 2
cibar support if condition == 2 | condition == 3, over1(condition) over2(three_tot) ///
	  barg(4) barc(gs1 gs7) ciopts(lc(gs10) lp(dash)) ///
	  gr(yti("              Policy support (proportion)" " ") ///
	  yli(0,lc(black)) ylab(0(0.2)1,nogrid) ///
	  xti(" " "Number of Items Checked") ///
	  graphr(c(white)) ///
	  leg(ring(0) pos(2) si(small) bm(medium)))
graph export "../figures/fig2.eps", replace

//SUPPLEMENTARY TABLE 2
eststo: logit support three ten control `balance', r
estadd local controls "Age"
eststo: logit support three##c.three_tot age female edu pol right energy_com if condition == 2 | condition == 3, r
estadd local controls "Full"
eststo: logit support three##c.right age female edu pol three_tot energy_com if condition == 2 | condition == 3, r
estadd local controls "Full"

esttab using "../tables/supptab2.rtf", replace compress onecell label se pr2 ///
	drop(age edu female pol energy_com _cons) nobaselevels star(* 0.10 ** 0.05 *** 0.01) ///
	scalar("controls Controls") ///
	rename(1.three three, 1.three_tot "# checked", 1.three#1.three_tot "3-item x # completed", ///
		1.three#1.right "3-item x ideology", 1.right "Ideology") ///
	mtitles ("ATE" "By # checked" "By ideology")	
eststo clear

//SUPPLEMENTARY TABLE 3
gen tokyo = 0
replace tokyo = 1 if prefecture == "Tokyo"
gen tohoku = 0
replace tohoku = 1 if prefecture == "Akita" | prefecture == "Aomori" | prefecture == "Fukushima" | ///
	prefecture == "Iwate" | prefecture == "Miyagi" | prefecture == "Yamagata"
gen kansai = 0
replace kansai = 1 if prefecture == "Mie" | prefecture == "Nara" | prefecture == "Wakayama" | ///
	prefecture == "Kyoto" | prefecture == "Osaka" | prefecture == "Hyogo" | prefecture == "Shiga"
gen target = 0
replace target = 1 if tokyo == 1 | tohoku == 1 | kansai == 1

eststo: logit support three##target age female edu pol right if condition == 2 | condition == 3, r
estadd local vs "Placebo"
estadd local controls "Yes"
eststo: logit support ten##target age female edu pol right if condition == 2 | condition == 4, r
estadd local vs "Placebo"
estadd local controls "Yes"
eststo: reg three_tot target age female edu pol right, r
estadd local vs "Placebo"
estadd local controls "Yes"
eststo: reg ten_tot target age female edu pol right, r
estadd local vs "Placebo"
estadd local controls "Yes"

esttab using "../tables/supptab3.rtf", replace compress onecell label se pr2 ///
	drop(age female edu pol right _cons) nobaselevels star(* 0.10 ** 0.05 *** 0.01) ///
	scalar("vs Baseline" "controls Controls") ///
	rename(1.three "3-item", 1.target "Target area", target "Target area", ///
	       1.three#1.target "3-item x Target area", 1.ten#1.target "10-item x Target area") ///
	mtitles ("Support (3-item)" "Support (10-item)" "# checked (3-item)" "# checked (10-item)")	
eststo clear


***MECHANISM**************************************************************

//Individual importance

eststo indcontrol: ologit energy_ind three ten placebo `balance' energy_pri moral_ppl moral_env, r
eststo indplacebo: ologit energy_ind three ten control `balance' energy_pri moral_ppl moral_env, r

//Issue importance

eststo pricontrol: ologit energy_pri three ten placebo `balance' energy_ind moral_ppl moral_env, r
eststo priplacebo: ologit energy_pri three ten control `balance' energy_ind moral_ppl moral_env, r

//Self-concept

foreach b in control placebo {
	foreach m in ppl env {
		eststo m`b'_`m': ologit moral_`m' three ten `b' `balance' energy_ind energy_pri, r
	}
}

//FIGURE 3

coefplot (indplacebo, mc(gs0) ciop(lc(gs0)) mlabcolor(gs0)), bylabel(Individual Importance) || ///
		 (mcontrol_ppl, mc(gs0) ciop(lc(gs0)) mlabcolor(gs0)), bylabel(Moral Self-Concept: People) || ///		
		 (priplacebo, mc(gs0) ciop(lc(gs0)) mlabcolor(gs0)), bylabel(Issue Importance) || ///
	     (mcontrol_env, mc(gs0) ciop(lc(gs0)) mlabcolor(gs0)), bylabel(Moral Self-Concept: Environment) ||, ///
	      drop(`balance' energy* moral* control _cons) eform ///
		  xline(1) xtitle(" " "              Odds ratios") xlab(0.75(0.25)1.25) ///
		  mlabel format(%9.2f) mlabposition(12) mlabgap(*2) graphr(c(white))
graph export "../figures/fig3.eps", replace
eststo clear

log close
